package com.wzq.app.ui;

import android.os.Bundle;
import android.view.View;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.wzq.app.R;
import com.wzq.app.base.BaseActivity;
import com.wzq.app.constant.App;
import com.wzq.app.manager.UserManager;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * @ProjectName: wzq
 * @Package: com.wzq.app.ui
 * @ClassName: UserInfoActivity
 * @Version: 1.0
 */
public class UserInfoActivity extends BaseActivity {
    @BindView(R.id.head_left)
    TextView headLeft;
    @BindView(R.id.info_name_value)
    TextView infoNameValue;
    @BindView(R.id.info_unit_value)
    TextView infoUnitValue;
    @BindView(R.id.info_sex_value)
    TextView infoSexValue;
    @BindView(R.id.info_mobile_value)
    TextView infoMobileValue;
    @BindView(R.id.info_type_value)
    TextView infoTypeValue;
    @BindView(R.id.info_userId)
    TextView infoUserId;
    @BindView(R.id.info_userId_value)
    TextView infoUserIdValue;
    @BindView(R.id.info_competent_value)
    TextView infoCompetentValue;
    @BindView(R.id.layout_competent)
    RelativeLayout layoutCompetent;

    @Override
    public int getLayoutId() {
        return R.layout.userinfo_activity;
    }

    @Override
    public void configView() {
        headLeft.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
        if (App.STUDENT.equals(UserManager.getInstance().getUser().getType())){
            infoUserId.setText("学号");
            infoUserIdValue.setText(UserManager.getInstance().getUser().getUserId());
        }else {
            infoUserId.setText("工号");
            infoUserIdValue.setText(UserManager.getInstance().getUser().getUserId());
        }
        if (App.TEACHER.equals(UserManager.getInstance().getUser().getType())){
            layoutCompetent.setVisibility(View.VISIBLE);
            infoCompetentValue.setText(UserManager.getInstance().getUser().getCompetent());
        }else {
            layoutCompetent.setVisibility(View.GONE);
        }
        infoNameValue.setText(UserManager.getInstance().getUser().getName());
        switch (UserManager.getInstance().getUser().getUnit()) {
            case "1":
                infoUnitValue.setText("一年级");
                break;
            case "2":
                infoUnitValue.setText("二年级");
                break;
            case "3":
                infoUnitValue.setText("三年级");
                break;
            case "4":
                infoUnitValue.setText("四年级");
                break;
            case "5":
                infoUnitValue.setText("五年级");
                break;
            case "6":
                infoUnitValue.setText("六年级");
                break;
            default:
                break;
        }
        infoMobileValue.setText(UserManager.getInstance().getUser().getMobile());
        if ("1".equals(UserManager.getInstance().getUser().getSex())) {
            infoSexValue.setText("男");
        } else {
            infoSexValue.setText("女");
        }
        switch (UserManager.getInstance().getUser().getType()) {
            case "0":
                infoTypeValue.setText("督导");
                break;
            case "1":
                infoTypeValue.setText("老师");
                break;
            case "2":
                infoTypeValue.setText("学生");
                break;
            default:
                break;
        }
    }

    @Override
    public void requestData() {

    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // TODO: add setContentView(...) invocation
        ButterKnife.bind(this);
    }
}
